import { useLocation, useRoutes } from "react-router-dom";
import Routers from "./router";
import RouterGuard from "./hooks/useRouterHandel";
import Tabbar from "./baseUI/tabbar";
import { useMemo } from "react";

function App() {
  const formatRouters = useRoutes(Routers);
  const route = useLocation();
  const showTabbar = useMemo(() => {
    return (
      Routers.find((item) => item.path === route.pathname)?.showTabbar ?? false
    );
  }, [route]);
  return (
    <>
      {formatRouters}
      {showTabbar && <Tabbar />}
    </>
  );
}

const WrappedApp = RouterGuard(App);
export default WrappedApp;
